<template>
  <div id="search">
      <div class="search1">    
      <i class="fa fa-search"></i>
      <input type="text" name="" v-model="searchText">
  </div>
 <div class="top">
   电影/电视剧/综艺
 </div>
  <div class="search2">
    <ul>
      <li v-for="item in searchDataList" :key="item.id">
<div class="first"><img :src="item.img" alt="" /></div>
        <div class="second">
          <p class="title">{{item.title}}</p>
          <p><span>{{item.actors}}</span></p>
          <p>{{item.nums}}</p>
        </div>
        <div class="third">{{item.score}}</div>
        </li>
         </ul>  
    </div>
   
    </div>
</template>
<script>
export default {
  name:"Search",
  data(){
    return{
      searchText:"",
      searchDataList:[],
    };
  },
  watch:{
    searchText(){
      axios
      .get("/mock/SearchData.json")
      .then((response)=>{
        if(response.status ===200){
          if(response.data && response.data.SearchData){
            this.searchDataList =response.data.SearchData.filter(
              (movie)=>{
                return movie.title.includes(this.searchText.trim());
              }
            )
          }
        }
      })
      .catch((err)=>{
        console.log(err);
      });
    },
  },
  
};
</script>
<style>
#search{
    width: 100%;
    padding-bottom: 50px;
}
.search2 div{
 float: left;
}
.top{
  color: #959998;
  font-size: 18px;
  padding: 10px;
   border-bottom:1px solid #ccc ;
   font-weight: bold;
}
i{
  position: absolute;
  margin: 8px;
}
.search1{
  background: #f5f5f5;
  padding: 10px;
}
input{
  width: 98%;
  height: 25px;
 
}

.first {
  width: 25%;
  margin-bottom: 8px;
}
.second {
  width: 55%;
  height: 40px;
  line-height: 40px;
}
.third {
  width: 15%;
  text-align: center;
  line-height: 75px;
  color: #ec7d3f;
  font-size: 30px;
  margin-top: -20px;
}
p {
  line-height: 25px;
}

img {
  width: 90px;
  height: 120px;

}
.search2 li{
  overflow: hidden;
  margin: 10px;
  border-bottom:1px dashed #ccc ;
}
.title{
  font-size: 20px;
  font-weight: bold;
}
</style>